package com.chenhao.springcloud.chenhaodatastructureservice.sort;

/**
 * Description:
 *
 * @author chenhao
 * @date 2020/12/3 14:00
 */
public class Student implements Comparable<Student> {

    private String name;

    private int score;

    public Student(String name,int score){
        this.name = name;
        this.score = score;
    }

    /**
     * 重写equals方法
     *
     * @param student
     * @return
     */
    @Override
    public boolean equals(Object student){
        if (this ==student) {
            return true;
        }
        if (student ==null){
            return false;
        }
        if (this.getClass()!=student.getClass()){
            return false;
        }
         Student another = (Student)student;
        return this.name.equals(another.name);
    }

    @Override
    public  int compareTo(Student another){
        return this.score -another.score;
    }

    @Override
    public String toString(){
        return String.format("student(name:%s,score:%d)",name,score);
    }


}
